home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10003 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.crystalball.com!news
  2. From: Larry Weiss <lfw@oc.com>
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr
  5. Date: Thu, 14 Mar 1996 15:27:43 -0600
  6. Organization: crystalball.com
  7. Message-ID: <31488F4F.726E@oc.com>
  8. References: <4i0946$7io@nuke.csu.net> <danpop.826545577@rscernix> <4i9dj4INN7kl@keats.ugrad.cs.ubc.ca> <4ia0kj$d8s@solutions.solon.com>
  9. NNTP-Posting-Host: external.oc.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14. CC: lfw@oc.com
  15.  
  16. Peter Seebach wrote:
  17.  > 
  18.  > In article <4i9dj4INN7kl@keats.ugrad.cs.ubc.ca>,
  19.  > Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
  20.  > >When I know that I'm specifically dealing with ASCII control chars, I have a
  21.  > >macro like:
  22.  > >#define CTRL(C) ((C)-64)
  23.  > >which I then use with capital letters:
  24.  > >       switch(char) {
  25.  > >       case CTRL('M'):
  26.  
  27.  > 
  28.  > I always use
  29.  >         #define CTRL(x) ((x) & 0x1f)
  30.  > because this preserves the likely semantics of CTRL.
  31.  
  32. Peter, Is this just a matter of self-evident documentation of the
  33.  macro definition?
  34.  
  35. Dan Pop, how would have coded Kazimir's example to avoid the
  36. reference to the magic-number 64 -and- how would you have coded
  37. Peter's alternative that uses magic-number 0x1f ?
  38.